package com.ssyc.common.quanzi;

import android.content.Context;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ssyc.common.R;
import com.ssyc.common.base.SpKeys;
import com.ssyc.common.utils.SPUtil;

import java.util.List;

/**
 * Created by Administrator on 2018/7/11 0011.
 */

public class CircleDetailsRvAdapter extends BaseQuickAdapter<QuanZiInfo.CirclelistBean.CommentlistBean, BaseViewHolder> {
    //上下文
    private Context context;

    public CircleDetailsRvAdapter(Context context, int layoutResId, @Nullable List<QuanZiInfo.CirclelistBean.CommentlistBean> data) {
        super(layoutResId, data);
        this.context = context;

    }

    @Override
    protected void convert(BaseViewHolder helper, QuanZiInfo.CirclelistBean.CommentlistBean item) {
        //第一个名字
        TextView tvFirstName = helper.getView(R.id.tv_name_first);

        //回复二字
        TextView tvCall = helper.getView(R.id.tv_call);

        //第二个名字
        TextView tvSecondName = helper.getView(R.id.tv_name_second);

        //评论的内容
        TextView tvContent = helper.getView(R.id.tv_content);
        tvContent.setText(item.getContent());

        if (!TextUtils.isEmpty(item.getUser_name2())) {
            tvCall.setVisibility(View.VISIBLE);
            tvSecondName.setVisibility(View.VISIBLE);
            //表示有回复
            if (TextUtils.isEmpty(item.getUser_name())) {
                //自己回复
                tvFirstName.setText(SPUtil.getString(context, SpKeys.NAME));
                tvSecondName.setText(item.getUser_name2());
            } else {
                //别人回复
                tvFirstName.setText(item.getUser_name());
                tvSecondName.setText(item.getUser_name2());
            }
        } else {
            //没有回复
            tvCall.setVisibility(View.GONE);
            tvSecondName.setVisibility(View.GONE);
            tvFirstName.setText(item.getUser_name());
        }

    }
}
